<template>
	<view style="padding-bottom:40rpx;">
		<view class="bg">
			<view class="mode" style="color: #666666;line-height: 60rpx;margin-bottom:20rpx;">
		        <view style="font-size: 32rpx;font-weight: bold;">
		          	用户信息
		        </view>
				<view>
					下单人：{{info.nickname || ''}}
				</view>
				<view>
					付款人：{{info.payNickname || ''}}
				</view>
			</view>
			<view class="mode" style="color: #666666;line-height: 60rpx;margin:20rpx auto;">
                <view style="font-size: 32rpx;font-weight: bold;">
                  	订单信息
					<u-button size="mini" class="order-status" type="primary" v-if="info.status < 3" @click="end(info)">结束订单</u-button>
					<u-button size="mini" class="order-status" type="error" v-else-if="info.status===3" >支付中</u-button>
					<u-button size="mini" class="order-status" type="success" v-else >已完成</u-button>
					
					<u-button size="mini" class="order-status" type="warning"  @click="tuikuan(info)">一键退款</u-button>
					
                </view>
				<view>
					订单编号：{{info.outTradeNo || ''}}
				</view>
				<view>
					门店：{{info.storeName || ''}}
				</view>
				<view>
					台位：{{info.carportName || ''}}
				</view>
				<view>
					消费时长：{{info.minute || 0}}分钟
				</view>
				<view>订单金额：￥{{info.totalMoney || 0}}</view>
				<view>支付余额：￥{{info.balance || 0}}</view>
				<view>支付现金：￥{{info.payMoney || 0}}</view>
				<view>创建时间：￥{{info.payTime || ''}}</view>
				<view>支付时间：￥{{info.payPayTime || ''}}</view>
			</view>
			
			<view class="mode" style="color: #666666;line-height: 60rpx;margin-top:20rpx;">
			    <view style="font-size: 32rpx;font-weight: bold;">
					优惠信息
			    </view>
				<view>优惠金额：￥{{info.saleMoney || 0}}</view>
				<view>优惠金额：￥{{info.saleMoney || 0}}</view>
				<view v-if="info.memberCouponId.length">优惠券：{{info.memberCouponId.length || 0}}张</view>
				<view v-if="info.mca">会员卡：{{info.mca.cardName || ''}}</view>
				<view v-if="info.mca">免费时长：{{info.mca.freeTime || 0}}分钟</view>
				<view v-if="info.mca">来源：{{info.mca.source || ''}}</view>
			</view>
			
		</view>


	</view>
</template>

<script>
	export default {
		data() {
			return {
				id:0,
				info:{}
			}
		},
		methods:{
			tuikuan(obj){
				this.$u.post('/alliance/refund', {
					id: obj.id
				}).then(res => {
					uni.showToast({
						title: '退款成功',
						icon:'success',
						duration:1500
					});
				});
			},
			end(item) {
			    //if(item.status > 3)return !1;
				//this.$u.toast('订单结束成功')
				
				uni.showModal({
					title: "温馨提示",
					content: '是否结束订单',
					success: (res) => {
						if (res.confirm) {
							this.$u.post('/alliance/finish', {
								order_id: item.id
							}).then(res => {
								uni.showToast({
									title: '订单结束成功',
									icon:'success',
									duration:1500
								});
							});
						}
					}
				})
			},
			getDetail(){
				this.$u.post('/indent/orderDetail', {
					order_id:this.id
				}).then(res => {
					console.log(res);
					this.info = res;
				}).catch(err => {})
			}
		},
		onLoad(options) {
			if (options.id) {
				this.id=options.id
				this.getDetail();
			}
		}
	}
</script>

<style>
	.bg {
		width: 750rpx;
		height: 200rpx;
		background: linear-gradient(-5deg, #0064C6, #2190FB);
		display: inline-block;
		padding-bottom:40rpx;
	}
	.mode{
		width: 695rpx;
	
		background: #FFFFFF;
		box-shadow: 6rpx 8rpx 8rpx 1rpx rgba(201, 201, 201, 0.19);
		border-radius: 12rpx;
		background: #FFFFFF;
		margin: 80rpx auto;
		padding: 30rpx;
	}
	.order-status{
		float:right;
	}
	
</style>
